#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

typedef struct BTNode
{
    char data;
    // L是左  child是孩子
    struct BTNode *pLchild, *pRchild;

} BTree, *PBTree;

//创建二叉树
void createBTree(PBTree *T)
{
    char ch;
    scanf("%c", &ch);
    if (ch == '#')
    {
        T = NULL;
    }
    else
    {
        PBTree T = (PBTree)malloc(sizeof(BTree));
        if (!T)
            return;
        T->data = ch;            //生成根节点
        createBTree(T->pLchild); //构造左子树
        createBTree(T->pRchild); //构造右子树
    }
}

int Depth(PBTree T) // 计算二叉树的深度
{
    if (T == NULL)
        return 0;
    else
    {
        int m = Depth(T->pLchild);
        int n = Depth(T->pRchild);
        return m > n ? (m + 1) : (n + 1);
        //最后+1返回给此时的根节点
    }
}

int count(PBTree T) // 计算叶子结点的个数
{
    if (T == NULL)
        return 0;
    int cnt = 0;
    if ((!T->pLchild) && (!T->pRchild))
    {
        cnt++;
    }
    int leftcnt = count(T->pLchild);  //计算左子树的叶子结点数
    int rightcnt = count(T->pRchild); //计算右子树的叶子结点数
    cnt += leftcnt + rightcnt;
    return cnt;
}